using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace Zhaoxi.MSACommerce.ProductService.UseCases;

public class NonEscapedStringConverter: JsonConverter
{
    public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
    {
        // 直接写入字符串而不转义
        writer.WriteRawValue(value.ToString());
    }

    public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)
    {
       return reader.Value?.ToString();
    }
    
   

    public override bool CanConvert(Type objectType)
    {
       return objectType == typeof(string);
    }
}